/*U41ajtHAnBXc4J9azvHa6ediPGD9LUURBy7KttFrrVq4t+wt2umvO59Wch1TMVGv*/
/*
 * @Author: xiahui 
 * @PageInfo: 付款计划编辑前
 * @Date: 2019-03-08 10:34:23 
 * @Last Modified by: zhr
 * @Last Modified time: 2021-08-27 15:34:51
 */
import { FIELDS } from '../../constance';
import { showWarningInfo } from '../../../../../scmpub/scmpub/pub/tool/messageUtil';
import { getLangByResId } from '../../../../../scmpub/scmpub/pub/tool/multiLangUtil';

export default async function(props, moduleId, item, index, value, record) {
	let key = item.attrcode;

	let beforeKeys = [
		FIELDS.feffdatetype,
		FIELDS.dbegindate,
		FIELDS.denddate,
		FIELDS.iitermdays,
		FIELDS.norigmny,
		FIELDS.nrate,
		FIELDS.bpreflag
	];

	if (beforeKeys.includes(key)) {
		let naccumpayorgmny = record.values[FIELDS.naccumpayorgmny].value;
		let naccumpayapporgmny = record.values[FIELDS.naccumpayapporgmny].value;
		if (naccumpayorgmny > 0 || naccumpayapporgmny > 0) {
			// 只允许编辑原币金额，账期到期日，比例
			if (FIELDS.norigmny != key && FIELDS.denddate != key && FIELDS.nrate != key) {
				showWarningInfo(
					null,
					getLangByResId(this, '4004PAYPLAN-000000')
				); /* 国际化处理： 已生成付款申请或付款单，只允许编辑原币金额，账期到期日字段*/
				return false;
			}
		}
	}
	let cannotedit = [ FIELDS.dratedate, FIELDS.fratecategory, FIELDS.cratetype ];
	if (cannotedit.includes(key)) {
		return false;
	}
	return true;
}

/*U41ajtHAnBXc4J9azvHa6ediPGD9LUURBy7KttFrrVq4t+wt2umvO59Wch1TMVGv*/